﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;
using MsDAL;
using System.ComponentModel;

namespace ServiceHelper
{
    [DataObjectAttribute]
    public partial class Pot3a00Manager : Pot3a00Base
    {
        private static Pot3a00Manager _entity;

        public static Pot3a00Manager Entity
        {
            get
            {
                if (_entity == null)
                    _entity = new Pot3a00Manager();
                return _entity;
            }
        }

        #region 个人代码

        public string SaveData(Hashtable tb, string action, string usercode)
        {
            List<SqlApp> lst = new List<SqlApp>();

            Pot3a00 model = null;
            if ("A" == action)
            {
                model = new Pot3a00();
                Components.CommonUtil.GetInstance.CopyProperties(tb, model);
                //添加维护者信息
                model.Muser = Context.GetAppByUserCode(usercode);

                //查询状态，默认为1
                model.Status = 1;

                //生成主键标识
                model.Listid = Sys0a60Manager.Entity.CreateSn("pot3a00_listid", usercode);
                //执行新增
                lst.Add(this.Add(model));
            }
            else if ("M" == action)
            {
                model = this.GetModelById(Components.Validation.ToString(tb["listid"]));

                if (model == null) return string.Format("商品代码({0})可能已经被删除，请重新操作！",
                    tb["productcode"]);

                Components.CommonUtil.GetInstance.CopyProperties(tb, model);
                //备份之前的商品资料
                lst.Add(Pot3b00Manager.Entity.Bak(Context.GetAppByUserCode(usercode), model.Listid, true, usercode));
                //修改商品资料
                lst.Add(this.Update(model));
                //备份修改后的资料
                lst.Add(Pot3b00Manager.Entity.Bak(Context.GetAppByUserCode(usercode), model.Listid, false, usercode));
            }

            return CommonManager.Entity.SaveData(lst);
        }

        #endregion

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pidId"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public SqlApp UpdateWayQty(string pidId, double qty)
        {
            return pot3a00Dal.UpdateWayQty(pidId, qty);
        }
    }
}



